﻿using System;
using Missbot.Service;
using MongoDB.Bson.Serialization.Attributes;

namespace Missbot.AIModule.Schedulers.DailyVtuber
{
    /// <summary>
    /// 每日Vtuber记录
    /// </summary>
    public class DailyVtuberRecord : DbBaseEntity
    {
        /// <summary>
        /// 发送日期
        /// </summary>
        [BsonDateTimeOptions(Kind = DateTimeKind.Local)]
        public DateTime SendTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 时间字符串
        /// </summary>
        public string DateStr { get; set; } = DateTime.Now.ToString("yyyyMMdd");
        
        /// <summary>
        /// Vtuber名称
        /// </summary>
        public string VtuberName { get; set; }
        
        /// <summary>
        /// 文件ID
        /// </summary>
        public string FileID { get; set; }
    }

    public static class DailyVtuberDA
    {
        /// <summary>
        /// 插入记录
        /// </summary>
        public static void Insert(this DailyVtuberRecord entity)
        {
            MongoService<DailyVtuberRecord>.Insert(entity);
        }

        /// <summary>
        /// 当天是否已经发送过
        /// </summary>
        /// <returns></returns>
        public static bool IsAlreadySend()
        {
            var dateStr = DateTime.Now.ToString("yyyyMMdd");
            return MongoService<DailyVtuberRecord>.Any(p => p.DateStr == dateStr);
        }
    }
}